makePrinter = function(id) {
    return function () {
        var form = document.createElement("form");
        form.action = 'http://printservice.sktdev.com/';
        form.method = "post";
        $(form).css("display", "none");
        var inp = document.createElement("input");
        inp.type = "hidden";
        inp.name = "va";
        var tag = $(id)[0].tagName;
        markup = "<" + tag + ">" + fixupHtml4Pdf( $(id).html() ) + "</" + tag + ">";
        inp.value = markup;
        form.appendChild(inp);
        $(document.body).append(form);
        form.submit();
    };
};


fixupHtml4Pdf = function (v) {
    v = v.replace(new RegExp("<img.*>", "gim"), "");
    v = v.replace(new RegExp("<a.*>", "gim"), "");
    return v;
};


var monthsArray = ['JAN','FEB','MAR','APR','MAY','JUN','JUL','AUG','SEP','OCT','NOV','DEC'];


function validMilitaryDate(date) {
    date = date.replace(/ /gi,"").toUpperCase();
    var day = date.substr(0,2);
    var month = jQuery.inArray(date.substr(2,3), monthsArray);
    var year = date.substr(5,4);
    if(year.length != 4){ return false; }
    var d = new Date();
    d.setFullYear(year,month,day);
    if(d.getDate() != day){ return false; }
    else if(d.getMonth() != month){ return false; }
    else if(d.getFullYear() != year){ return false; }
return true;
}


function convertMilitaryDate(date) {
    date = date.replace(/ /gi,"").toUpperCase();
    var day = date.substr(0,2);
    day = ( (day.length < 2) ? '0' + day : day );
    var month = String(jQuery.inArray(date.substr(2,3), monthsArray) + 1);
    month = ( (month.length < 2) ? '0' + month : month );
    var year = date.substr(5,4);
    date = year + '-' + month + '-' + day;
return date;
}


function convertToMilitaryDate(date) {
    date = date.replace(/-/gi,"");
    var day = date.substr(6,2);
    var month = monthsArray[ parseInt(date.substr(4,2)-1,10) ];
    var year = date.substr(0,4);
    date = day + ' ' + month + ' ' + year;
return date;
}


function getQueryStringVariable(variable) {
  var query = window.location.search.substring(1);
  var vars = query.split("&");
  for (var i=0;i<vars.length;i++) {
    var pair = vars[i].split("=");
    if (pair[0] == variable) {
      return pair[1];
    }
  } 
  return false;
}


jQuery(function($) {
    $("a.logout:contains(Logout)").click( function(){
        jQuery.ajax({
	    url:"/api/logout/",
            type:"POST",
            data:{},
            success: function(){ document.location = "/ocie/"; },
            error: function(){ document.location = "/ocie/"; }
        });
        return false;   
   });
});



